#pragma once

#include "AsyncLibDef.h"

namespace AsyncLib
{

class CThreadpoolWork
{
public:
	CThreadpoolWork(UINT nMinThreads, UINT nMaxThreads);
	~CThreadpoolWork();

	void Init();
	void Stop();
	void Exit();
	void PostTask(std::function<void()>&& fnTask);

private:
	void OnCallback();

	UINT       m_nMinThreads;
	UINT       m_nMaxThreads;
	UINT       m_nCurThreads;
	PTP_WORK   m_pTpWork;
	std::mutex m_mutex;
	std::deque<std::function<void()>> m_deqTasks;
};

} // namespace AsyncLib
